home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Path: cwi.nl!dik
- From: dik@cwi.nl (Dik T. Winter)
- Subject: Re: Access carry flag from C
- Message-ID: <Dnssxu.JGy@cwi.nl>
- Sender: news@cwi.nl (The Daily Dross)
- Nntp-Posting-Host: chrysant.cwi.nl
- Organization: CWI, Amsterdam
- References: <4h1veoINNlns@anvil.ugrad.cs.ubc.ca> <fgrieu-0403961143580001@ppp78.micronet.fr> <4hhbt8$1d3o@b.stat.purdue.edu>
- Date: Tue, 5 Mar 1996 14:15:29 GMT
-
- In article <4hhbt8$1d3o@b.stat.purdue.edu> hrubin@b.stat.purdue.edu (Herman Rubin) writes:
- > In article <fgrieu-0403961143580001@ppp78.micronet.fr>,
- > Franτois Grieu <fgrieu@micronet.fr> wrote:
- >
- > > if (x + yl < yl) ++yh; /* test for overflow on next line */
- > > yl += x;
- ...
- > Notice that in the above code, each addition must be performed twice.
-
- Wrong. Even a mediocre compiler will optimize this away.
-
- > BTW, there is a weakness in the code; ++yh can cause a carry, so
- > another test is needed. As testing is expensive, what is needed in
- > this case is not a test for carry, but the ability to add the carry
- > bit to something.
-
- But the code above also works on machines without carry bit.
- --
- dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924098
- home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
-